/*
 * @Author: 吕佳伟
 * @Date: 2021-03-31 21:52:04
 * @LastEditors: 吕佳伟
 * @LastEditTime: 2021-07-03 21:36:32
 * @Description: file content
 */
import 'dart:convert';
import 'package:flutter/material.dart';
import '../models/ClassResponseData.dart';
import '../models/ClassItemViewModel.dart';
import './GetColorList.dart';

///课程列表向构造类
///吕佳伟
List<ClassItemViewModel> getADayClasses(ClassResponseData data) {
  List<List<ClassItemViewModel>> tap = data.data.result.map((oneCourseInfo) {
    String courseName = oneCourseInfo.course_id.name; // 课程名
    String teacherName = oneCourseInfo.teacher_id.name; // 教师名
    String ClassID = oneCourseInfo.lesson_id; //课程Id
    List<Color> itemColors = GetColorList(); // 卡片颜色
    return oneCourseInfo.curriculum.map((classTime) {
      String order = ""; // 上课时间
      classTime.order.forEach((value) {
        order += "$value,";
      });
      order = order.replaceRange(order.length - 1, order.length, '节');
      String campus = classTime.room_id.campus_name;
      String classPlace = classTime.room_id.building_name +
          classTime.room_id.room_name +
          classTime.room_id.room_number.toString();
      String dateD = classTime.date;
      return ClassItemViewModel(courseName, classPlace, teacherName, campus,
          itemColors, order, dateD, ClassID);
    }).toList();
  }).toList();
  List<ClassItemViewModel> results = [];
  tap.forEach((e2) {
    e2.forEach((element) {
      results.add(element);
    });
  });
  return results;
}

Map<String, dynamic> getJson() {
  String jsonStr =
      '{"status":"success","data":{"result":[{"_id":"0d5ed310-832c-11eb-af69-cf8b203a7285","course_id":{"_id":"4f9d1bb0-8246-11eb-bcc8-751424e2529d","name":"项目过程管理","id":"4f9d1bb0-8246-11eb-bcc8-751424e2529d"},"lesson_id":"9909a2b0-832b-11eb-af69-cf8b203a7285","teacher_id":{"_id":"bf0481b0-8245-11eb-bcc8-751424e2529d","name":"任美睿","id":"bf0481b0-8245-11eb-bcc8-751424e2529d"},"curriculum":[{"order":["1","2","3","4","5","6","7","8","9","10"],"odd_or_even":0,"class_id":{"class_name":"2019级1班","id":null},"room_id":{"room_name":"报告厅","room_size":0,"room_status":"using","_id":"294ddf50-8325-11eb-83e1-7f120a53dbef","room_number":1354,"room_type":"办公室","building_name":"文津楼","campus_name":"长安校区","org_name":"陕西师范大学","room_users":[],"__v":0,"living_lessonID":"9909a2b0-832b-11eb-af69-cf8b203a7285","deviceBoxIP":"192.168.188.217"},"date":"Sat"},{"order":["1","2","3","4","5","6","7","8","9","10"],"odd_or_even":0,"class_id":{"class_name":"2019级1班","id":null},"room_id":{"room_name":"报告厅","room_size":0,"room_status":"using","_id":"294ddf50-8325-11eb-83e1-7f120a53dbef","room_number":1354,"room_type":"办公室","building_name":"文津楼","campus_name":"长安校区","org_name":" 陕西师范大学","room_users":[],"__v":0,"living_lessonID":"9909a2b0-832b-11eb-af69-cf8b203a7285","deviceBoxIP":"192.168.188.217"},"date":"Sun"},{"order":["1","2","3","4","5","6","7","8","9","10"],"odd_or_even":0,"class_id":{"class_name":"2019级1班","id":null},"room_id":{"room_name":"报告厅","room_size":0,"room_status":"using","_id":"294ddf50-8325-11eb-83e1-7f120a53dbef","room_number":1354,"room_type":"办公室","building_name":"文津楼","campus_name":"长安校区","org_name":"陕西师 范大学","room_users":[],"__v":0,"living_lessonID":"9909a2b0-832b-11eb-af69-cf8b203a7285","deviceBoxIP":"192.168.188.217"},"date":"Tue"},{"order":["1","2","3","4","5","6","7","8","9","10"],"odd_or_even":0,"class_id":{"class_name":"2019级1班","id":null},"room_id":{"room_name":"报告厅","room_size":0,"room_status":"using","_id":"294ddf50-8325-11eb-83e1-7f120a53dbef","room_number":1354,"room_type":"办公室","building_name":"文津楼","campus_name":"长安校区","org_name":"陕西师范大学","room_users":[],"__v":0,"living_lessonID":"9909a2b0-832b-11eb-af69-cf8b203a7285","deviceBoxIP":"192.168.188.217"},"date":"Mon"},{"order":["1","2","3","4","5","6","7","8","9","10"],"odd_or_even":0,"class_id":{"class_name":"2019级1班","id":null},"room_id":{"room_name":"报告厅","room_size":0,"room_status":"using","_id":"294ddf50-8325-11eb-83e1-7f120a53dbef","room_number":1354,"room_type":"办公室","building_name":"文津楼","campus_name":"长安校区","org_name":"陕西师范大学","room_users":[],"__v":0,"living_lessonID":"9909a2b0-832b-11eb-af69-cf8b203a7285","deviceBoxIP":"192.168.188.217"},"date":"Wed"},{"order":["1","2","3","4","5","6","7","8","9","10"],"odd_or_even":0,"class_id":{"class_name":"2019级1班","id":null},"room_id":{"room_name":"报告厅","room_size":0,"room_status":"using","_id":"294ddf50-8325-11eb-83e1-7f120a53dbef","room_number":1354,"room_type":"办公室","building_name":"文津楼","campus_name":"长安校区","org_name":"陕西师范大学","room_users":[],"__v":0,"living_lessonID":"9909a2b0-832b-11eb-af69-cf8b203a7285","deviceBoxIP":"192.168.188.217"},"date":"Thu"},{"order":["1","2","3","4","5","6","7","8","9","10"],"odd_or_even":0,"class_id":{"class_name":"2019级1班","id":null},"room_id":{"room_name":"祁老师和张老师的家","room_size":0,"room_status":"avaliable","_id":"4bf8e830-88af-11eb-9f7a-cbf5e8c35e4b","room_number":3624,"room_type":"实验室","building_name":"文津楼","campus_name":"长安校区","org_name":"陕西师范大学","room_users":[],"__v":0},"date":"Sun"}],"__v":0,"semester":1,"year":"2021-2022"},{"_id":"c1a74fa0-8480-11eb-af59-1b107feda33a","course_id":{"_id":"4f9db7f0-8246-11eb-bcc8-751424e2529d","name":"操作系统","id":"4f9db7f0-8246-11eb-bcc8-751424e2529d"},"lesson_id":"97266bd0-8480-11eb-af59-1b107feda33a","teacher_id":{"_id":"bf0481b1-8245-11eb-bcc8-751424e2529d","name":"武杰","id":"bf0481b1-8245-11eb-bcc8-751424e2529d"},"curriculum":[{"order":["4","5"],"odd_or_even":0,"class_id":{"class_name":"2019级1班","id":null},"room_id":{"room_name":"报告厅","room_size":0,"room_status":"using","_id":"294ddf50-8325-11eb-83e1-7f120a53dbef","room_number":1354,"room_type":"办公室","building_name":"文津楼","campus_name":"长安校区","org_name":"陕西师范大学","room_users":[],"__v":0,"living_lessonID":"9909a2b0-832b-11eb-af69-cf8b203a7285","deviceBoxIP":"192.168.188.217"},"date":"Sun"},{"order":["7"],"odd_or_even":0,"class_id":{"class_name":"2019级1班","id":null},"room_id":{"room_name":"数据安全","room_size":0,"room_status":"avaliable","_id":"df3f26c0-8893-11eb-ae68-3563477c4edf","room_number":3602,"room_type":"实验室","building_name":"文津楼","campus_name":"长安校区","org_name":"陕西师范大学","room_users":[],"__v":0},"date":"Sun"}],"__v":0,"semester":1,"year":"2020-2021"}]}}';
  return json.decode(jsonStr);
}
